package FirstProject;

import java.util.zip.CheckedOutputStream;

//超人套餐
public class SuperPackage extends ServicePackage implements SendService,CallService,NetService{
    int talkTime=200;
    int smsCount=50;
    int flow=1;
    double price=78;

    public SuperPackage(double price) {
        super(price);
    }

    public SuperPackage(int talkTime, int smsCount, int flow, double price) {
        super(78);
        this.talkTime = talkTime;
        this.smsCount = smsCount;
        this.flow = flow;
        this.price = price;
    }
    public void showInfo(){
        System.out.println("超人套餐" +price+"元/月"
                +"消息:"+smsCount+"条/月"+ ",流量:"
                +flow+"GB/月"+"通话时长:"+talkTime+"分钟/月"
        );
    }
    public int getTalkTime() {
        return talkTime;
    }

    public void setTalkTime(int talkTime) {
        this.talkTime = talkTime;
    }

    public int getSmsCount() {
        return smsCount;
    }

    public void setSmsCount(int smsCount) {
        this.smsCount = smsCount;
    }

    public int getFlow() {
        return flow;
    }

    public void setFlow(int flow) {
        this.flow = flow;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public int send(int count, MobileCard card) {
        int extra=0;
        if(count<=smsCount){
            count-=smsCount;
        }else {
            extra=count-smsCount;
            smsCount=0;
            card.consumeAmount+=extra*0.2;
        }
        card.realSMSCount+=count;
        return extra;
    }

    @Override
    public int netPlay(int flow, MobileCard card) {
        int extra=0;
        if(flow<=this.flow){
            flow-=this.flow;
        }else {
            extra=flow-this.flow;
            this.flow=0;
            card.consumeAmount+=(extra/1024)*0.1;
        }
        card.realFlow+=flow;
        return extra;
    }

    @Override
    public int call(int minCount, MobileCard card) {
        return 0;
    }
}
interface SendService{
    int send(int count,MobileCard card);
}